/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.fee.core.repository.mapper;

import info.peigen.hotpot.business.fee.core.repository.entity.FeeLogEntity;
import info.peigen.hotpot.business.fee.facade.enums.FeeAction;
import info.peigen.hotpot.business.fee.facade.enums.FeeProductCode;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

import java.util.List;

/**
 * <b>(FeeLogMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/1
 */
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
public interface FeeLogMapper extends AbstractBeetlSqlMapper<FeeLogEntity> {
    @Sql("select * from fee_log where fee_log_id = ?")
    @Select
    FeeLogEntity findByFeeLogId(String feeLogId);

    @Sql("select * from fee_log where trade_id = ?")
    @Select
    List<FeeLogEntity> findByTradeId(String tradeId);

    @Sql("select * from fee_log where trade_id = ? and action = ? order by create_time desc")
    @Select
    List<FeeLogEntity> findByTradeIdAndAction(String tradeId, FeeAction action);

    @Sql("select * from fee_log where account_id = ? and action = ? and code = ?")
    @Select
    FeeLogEntity findByAction(String accountId, FeeAction action, FeeProductCode code);

    @Sql("select * from fee_log where account_id = ?")
    @Select
    List<FeeLogEntity> listByAccountId(String accountId);

    @Sql("delete from fee_log where fee_log_id = ?")
    @Update
    void deleteByFeeId(String feeLogId);

    @Sql("delete from fee_log where trade_id = ?")
    @Update
    void deleteByTradeId(String tradeId);

    @Sql("delete from fee_log where account_id = ?")
    @Update
    void deleteByAccountId(String accountId);
}